package com.example.picturestorage.utils;

import org.springframework.stereotype.Component;

import java.util.HashSet;

@Component
public class StringUtils {
    public static void main(String[] args) {
        HashSet<Integer> integers = new HashSet<>();
        for (int i = 0; i < 100; i++) {
            integers.add((int) (Math.random() * 26) + 97);
        }
        System.out.println(integers);
        System.out.println((char) 97);
        System.out.println((char) (97 + 25));
        System.out.println(new StringUtils().randomString());
    }

    public String randomString() {
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < 6; i++) {
            s.append(toUpperCase(randomChar()));
        }
        return s.toString();
    }

    private char randomChar() {
        return (char) ((Math.random() * 26 + 97));
    }

    private boolean isUpperCase() {
        int i = (int) (Math.random() * 2);
        return i != 0;
    }

    private String toUpperCase(char c) {
        String s = "";
        String cStr = c + "";
        return isUpperCase() ? s += cStr.toUpperCase() : cStr;
    }
}
